package com.example.lin.day8_31.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.example.lin.day8_31.utils.LogUtils;

public class MyDBOpenhelper extends SQLiteOpenHelper {

    private static final String DB_NAME = "my-db";
    private static final int DB_VERSION = 1;

    public static final String TABLE_NAME = "student";
    public static final String COLUMN_ID = "_id";
    public static final String COLUMN_NAME = "_name";
    public static final String COLUMN_AGE = "_age";
    public static final String COLUMN_SEX = "_sex";

    public MyDBOpenhelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "CREATE TABLE " + TABLE_NAME + " (" +
                COLUMN_ID + " INTEGER primary key autoincrement," +
                COLUMN_NAME + " text," +
                COLUMN_AGE + " integer," +
                COLUMN_SEX + " text" +
                ");";
        LogUtils.info(sql);
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
